import type {
    OperatorType,
    OperatorInfoType,
} from "./types";
import type { computeFnType } from "../commonType";

export class Operator implements OperatorType {
    #operatorInfo: OperatorInfoType;
    // 操作符的行为函数
    action: computeFnType;

    constructor(operatorInfo: OperatorInfoType, actionFn: computeFnType) {
        this.#operatorInfo = operatorInfo;
        this.action = actionFn;
    };

    /**
     * 获取实例的运算符
     * @returns 实例的运算符："+" | "-" | "*" | "/" | "%"
     */
    getBasic() {
        return this.#operatorInfo.basic;
    }
    /**
     * 获取该运算符的运算相对优先级
     * @returns 该运算符的运算相对优先级1 | 2
     */
    getPriority() {
        return this.#operatorInfo.priority;
    }
    /**
     * 获取实例的运算符页面显示名称
     * @returns 实例的运算符式子显示名称："加" | "减" | "乘" | "除以" | "取余"
     */
    getQuote() {
        return this.#operatorInfo.quote;
    }
}